<template>
	<view class="person_feedback">
		<view class="no_html" v-if="list.length==0">
			<image src="@/static/images/no_img1.png" mode=""></image>
			<text>当前暂无反馈信息</text>
		</view>
		<view class="feed_main" v-else>
			<view class="list" v-for="(item,index) in list" :key="index">
				<view class="title">
					反馈类型：{{item.type}} <text @click="delBtn(index,item.id)">删除</text>
				</view>
				<view class="content">
					{{item.content}}
				</view>
				<view class="image" v-if="item.image && item.image.length">
					<image v-for="(ite,idx) in item.image" :key="idx" :src="ite" @click="imageBtn(idx,index)" mode="aspectFill"></image>
				</view>
			</view>
			<view class="mall_loading" v-if="list.length">
				<u-loadmore :status="status" color='#999' />
			</view>
		</view>
		<!-- 底部 -->
		<BottomBtn title='反馈' @submit='submitBtn'></BottomBtn>
	</view>
</template>

<script>
	import BottomBtn from '@/components/bottom_btn/bottom_btn.vue';
	export default {
		components:{
			BottomBtn
		},
		data() {
			return {
				status: 'loadmore', //加载前值为loadmore，加载中为loading，没有数据为nomore
				page: 1,
				list: [],
			};
		},
		onLoad() {
			
		},
		onShow(){
			this.feedList()
		},
		methods:{
			feedList(){
				var that = this
				if(that.page==1){
					that.$tips.showLoading('加载中')
				}else{
					that.status = 'loading'
				}
				that.$httpApi.userfeedback().then((res) => {
					if (res.code == 1) {
						that.total_money=res.data.total_money
						if (that.page == 1) {
							that.list = []
							that.$tips.hideLoading()
						}
						if (res.data.current_page == res.data.last_page) {
							that.status = 'nomore'
						} else {
							that.status = 'loadmore'
						}
						that.list = that.list.concat(res.data.data)
					}
				})
			},
			imageBtn(idx,index){
				var arr = this.list[index].image
				uni.previewImage({
					current:idx,
					urls: arr,
				})
			},
			// 删除
			delBtn(index,val){
				var that = this
				that.$tips.showLoading('删除中')
				var params = {
					ids:val
				}
				that.$httpApi.userfeedbackDel(params).then((res)=>{
					that.$tips.hideLoading()
					if(res.code==1){
						that.list.splice(index,1)
						that.$tips.showToast('删除成功')
					}
				})
			},
			// 底部按钮
			submitBtn(){
				uni.navigateTo({
					url:'/pages/person/person_feedback_need'
				})
			},
		},
		onReachBottom() {
			if (this.status == 'nomore' || this.status == 'loading') {
				return
			}
			this.page++
			this.getList()
		},
	}
</script>

<style lang="less">
	.person_feedback{
		width: 100%;
	}
	.feed_main{
		width: 100%;
		padding-top: 24rpx;
		.list{
			width: 100%;
			padding: 0 32rpx 24rpx;
			margin-bottom: 24rpx;
			background: #fff;
			.title{
				width: 100%;
				height: 80rpx;
				font-size: 30rpx;
				color: #333;
				display: flex;
				align-items: center;
				justify-content: space-between;
				text{
					font-size: 26rpx;
					color: #26C281;
				}
			}
			.content{
				width: 100%;
				font-size: 28rpx;
				color: #666;
			}
			.image{
				width: 100%;
				padding-top: 20rpx;
				display: flex;
				image{
					display: block;
					width: 164rpx;
					height: 164rpx;
					margin-right: 10rpx;
				}
				image:nth-child(4n){
					margin-right: 0;
				}
			}
		}
	}
</style>
